home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Snippets
/
Help Dialog
/
helptester.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-25
|
4KB
|
141 lines
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
// helptester.c
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
// …………………………………………………………………………………………………………………………………………………………………………………………………………… includes
#include <Windows.h>
#include <Fonts.h>
#include <Menus.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <SegLoad.h>
#include <ToolUtils.h>
#include <Resources.h>
#include <Balloons.h>
// ……………………………………………………………………………………………………………………………………………………………………………………………………………… defines
#define rMenuBar 128
#define mApple 128
#define mFile 129
#define iQuit 11
#define MAXLONG 0x7FFFFFFF
// ……………………………………………………………………………………………………………………………………………………………………………………………………………… globals
Boolean gDone = false;
// ……………………………………………………………………………………………………………………………………………………………………………… function prototypes
void main (void);
void doInitManagers (void);
void doEvents (EventRecord *);
void doHelpMenu (SInt16);
extern void doHelp (void);
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ main
void main(void)
{
Handle menubarHdl;
MenuHandle menuHdl;
OSErr osErr;
EventRecord eventRec;
doInitManagers();
menubarHdl=GetNewMBar(rMenuBar);
if(menubarHdl == NULL)
ExitToShell();
SetMenuBar(menubarHdl);
DrawMenuBar();
menuHdl = GetMenuHandle(mApple);
if(menuHdl != NULL)
AppendResMenu(menuHdl,'DRVR');
else
ExitToShell();
osErr = HMGetHelpMenuHandle(&menuHdl); /////////
if(osErr == noErr) /////////
AppendMenu(menuHdl,"\pHelp Dialog Help…"); /////////
else /////////
ExitToShell(); /////////
while(!gDone)
{
if(WaitNextEvent(everyEvent,&eventRec,MAXLONG,NULL))
doEvents(&eventRec);
}
}
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ doInitManagers
void doInitManagers(void)
{
MaxApplZone();
MoreMasters();
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
}
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ doEvents
void doEvents(EventRecord *eventRecPtr)
{
SInt16 partCode, menuID, menuItem;
WindowPtr windowPtr;
SInt32 menuChoice;
switch(eventRecPtr->what)
{
case mouseDown:
partCode = FindWindow(eventRecPtr->where,&windowPtr);
if(partCode == inMenuBar)
{
menuChoice = MenuSelect(eventRecPtr->where);
menuID = HiWord(menuChoice);
menuItem = LoWord(menuChoice);
switch(menuID)
{
case mFile:
if(menuItem == iQuit)
gDone = true;
break;
case kHMHelpMenuID: /////////
doHelpMenu(menuItem); /////////
break; /////////
}
}
break;
}
}
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ doHelpMenu
void doHelpMenu(SInt16 menuItem) /////////
{
MenuHandle helpMenuHdl; /////////
SInt16 origHelpItems, numItems; /////////
HMGetHelpMenuHandle(&helpMenuHdl); /////////
numItems = CountMItems(helpMenuHdl); /////////
origHelpItems = numItems - 1; /////////
if(menuItem > origHelpItems) /////////
doHelp(); /////////
}
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊